/* stylelint-disable color-hex-length */
@import '../style/var.less';

.van-calendar {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  .theme(height, '@calendar-height');
  .theme(background-color, '@calendar-background-color');

  &__close-icon {
    top: 22px;
  }

  &__popup--top,
  &__popup--bottom {
    .theme(height, '@calendar-popup-height');
  }

  &__popup--left,
  &__popup--right {
    height: 100%;
  }

  &__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  &__footer {
    flex-shrink: 0;
    .theme(padding, '0 @padding-md');

    &--safe-area-inset-bottom {
      padding-bottom: constant(safe-area-inset-bottom);
      /* stylelint-disable-next-line */
      padding-bottom: env(safe-area-inset-bottom);
    }
  }

  &__footer:empty,
  &__footer + &__footer {
    display: none;
  }

  &__footer:empty + &__footer {
    display: block !important;
  }

  &__confirm {
    .theme(height, '@calendar-confirm-button-height') !important;
    .theme(margin, '@calendar-confirm-button-margin') !important;
    .theme(line-height, '@calendar-confirm-button-line-height') !important;
  }
}

/* stylelint-disable-next-line */
.van-calendar {
  &__header {
    flex-shrink: 0;
    .theme(box-shadow, '@calendar-header-box-shadow');
  }

  &__header-title,
  &__header-subtitle {
    text-align: center;

    .theme(height, '@calendar-header-title-height');
    .theme(font-weight, '@font-weight-bold');
    .theme(line-height, '@calendar-header-title-height');
  }

  // &__header-title:empty,
  // &__header-title + &__header-title {
  //   display: none;
  // }

  &__header-title:empty + &__header-title {
    display: block !important;
  }

  &__weekdays {
    display: flex;
  }

  &__weekday {
    flex: 1;
    text-align: center;

    .theme(font-size, '@calendar-weekdays-font-size');
    .theme(line-height, '@calendar-weekdays-height');
  }
}

/* stylelint-disable-next-line */
.van-calendar {
  display: flex;
  flex-direction: column;
  height: 100%;
  .theme(background-color, '@calendar-background-color');

  &__month-title {
    text-align: center;
    .theme(height, '@calendar-header-title-height');
    .theme(font-weight, '@font-weight-bold');
    .theme(font-size, '@calendar-month-title-font-size');
    .theme(line-height, '@calendar-header-title-height');
  }

  &__days {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    user-select: none;
  }

  &__month-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;

    .theme(color, '@calendar-month-mark-color');
    .theme(font-size, '@calendar-month-mark-font-size');
  }

  &__day,
  &__selected-day {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  &__day {
    position: relative;
    width: 14.285%;

    .theme(height, '@calendar-day-height');
    .theme(font-size, '@calendar-day-font-size');

    &--end,
    &--start,
    &--start-end,
    &--multiple-middle,
    &--multiple-selected {
      .theme(color, '@calendar-range-edge-color');
      .theme(background-color, '@calendar-range-edge-background-color');
    }

    &--start {
      .theme(border-radius, '@border-radius-md 0 0 @border-radius-md');
    }

    &--end {
      .theme(border-radius, '0 @border-radius-md @border-radius-md 0');
    }

    &--start-end,
    &--multiple-selected {
      .theme(border-radius, '@border-radius-md');
    }

    &--middle {
      .theme(color, '@calendar-range-middle-color');

      &::after {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: currentcolor;
        content: '';

        .theme(opacity, '@calendar-range-middle-background-opacity');
      }
    }

    &--disabled {
      cursor: default;

      .theme(color, '@calendar-day-disabled-color');
    }
  }

  &__top-info,
  &__bottom-info {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 0;
    left: 0;
    .theme(font-size, '@calendar-info-font-size');
    .theme(line-height, '@calendar-info-line-height');
  }

  &__top-info {
    top: 6px;
  }

  &__bottom-info {
    bottom: 6px;
  }

  &__selected-day {
    .theme(width, '@calendar-selected-day-size');
    .theme(height, '@calendar-selected-day-size');
    .theme(color, '@calendar-selected-day-color');
    .theme(background-color, '@calendar-selected-day-background-color');
    .theme(border-radius, '@border-radius-md');
  }
}

.van-calendar-longspan {
  padding: 30px;
  background: #fff;
  height: 100%;
  position: absolute;
  z-index: 999;
  box-sizing: border-box;
  width: 100%;

  /* stylelint-disable-next-line no-descending-specificity */
  .van-calendar-longspan-title {
    margin-bottom: 30px;
    font-weight: bold;
  }

  .van-calendar-longspan-content {
    height: calc(100% - 200px);
    overflow: auto;
  }

  .van-calendar-longspan-box {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    /* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
    flex-wrap: wrap;
  }

  .van-calendar-longspan-item {
    /* stylelint-disable-next-line length-zero-no-unit */
    margin: 0px 20px 20px 0px;
  }

  .van-calendar__switch {
    position: absolute;
    z-index: 999;
    bottom: 30px;
    left: 30px;
    width: calc(100% - 60px);
  }
}
